﻿using commonImportPlugin.Common;
using commonImportPlugin.Configs.MatchFile;
using commonImportPlugin.Core.FilesCore.MatchFile;
using ICMS.PluginInterfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace commonImportPlugin.Factorys
{
    //
    //  抽象工厂
    //
    #region
    /// <summary>
    /// 匹配文件抽象工厂
    /// </summary>
    public abstract class AbstractMatchFile
    {
        public abstract MatchFileCore CreateMatchFileCore(params object[] list);
    }
    /// <summary>
    /// 匹配文件处理工厂类
    /// </summary>
    public abstract class MatchFileCore
    {
        /// <summary>
        /// 获取所有匹配数据
        /// </summary>
        public abstract List<ICData> GetMatchAllDatas(List<string> matchFilePaths, out int matchCounts);
        /// <summary>
        /// 检查匹配数据
        /// </summary>
        public abstract bool CheckMatchData(string matchFilePath, string regexstr);
        /// <summary>
        /// 获取所有匹配数据量
        /// </summary>
        public abstract int GetMatchAllCounts(List<string> matchFilePaths);

    }
    #endregion

    //
    //  工厂集
    //
    #region
    public class MatchFileCoreFactory : AbstractMatchFile
    {
        public override MatchFileCore CreateMatchFileCore(params object[] list)
        {
            MatchFileCoreClass core = new MatchFileCoreClass();
            return core.GetInstance();
        }
    }
    #endregion

    //
    //  简单工厂
    //
    #region
    /// <summary>
    /// 匹配文件普通模式
    /// </summary>
    public class setMatchFileCoreFactory
    {
        public MatchFileCore CreateFactory(string whichFactory)
        {
            switch (whichFactory)
            {
                case "General":
                    //初始化配置
                    MatchFileConfig matchFileConfig = new MatchFileConfig();
                    matchFileConfig.Init();
                    //返回初始化核心
                    return new MatchFileCoreFactory().CreateMatchFileCore();
                default:
                    break;
            }
            return null;
        }
    }
    #endregion

}
